package org.dromara.job.snailjob;

import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.domain.R;
import org.dromara.system.api.RemotePayService;
import org.springframework.stereotype.Component;

/**
 * @author opensnail
 * @date 2024-05-17
 */
@Component
@JobExecutor(name = "refreshRateJobExecutor")
public class RefreshRateJobExecutor {

    @DubboReference
    private RemotePayService remotePayService;

    public ExecuteResult jobExecute(JobArgs jobArgs) {
        R<?> r = remotePayService.payRateRefresh();
        if(R.isSuccess(r)) {
            return ExecuteResult.success("汇率刷新成功");
        } else {
            return ExecuteResult.failure(r.getMsg());
        }
    }
}

